package com.dzbh.cdsdriver.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.dzbh.cdsdriver.R;
import com.dzbh.cdsdriver.model.BillBean;

import java.util.List;

/**
 * Created by dongxinguang on 2016/11/19.
 */

public class NewBillsAdapter extends RecyclerView.Adapter<NewBillsAdapter.NewsViewHolder>{
    private Context mContext;
    private List<BillBean> mDataList;
    private LayoutInflater mInflater;
    public NewBillsAdapter(Context context) {
        this.mContext = context ;
        mInflater = LayoutInflater.from(mContext);
    }

    public void setmDataList(List<BillBean> mDataList) {
        this.mDataList = mDataList;
    }

    @Override
    public NewsViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new NewsViewHolder(mInflater.inflate(R.layout.newbill_item,parent,false));
    }

    @Override
    public void onBindViewHolder(NewsViewHolder holder, int position) {
        BillBean billBean = mDataList.get(position);
        holder.indexTv.setText(String.format(mContext.getString(R.string.newbills_item), (position + 1)));
        holder.addressTv.setText(billBean.getGoal());
        Log.d("dong", "position->" + position);
    }

    @Override
    public int getItemCount() {
        return mDataList.size();
    }

    public class NewsViewHolder extends RecyclerView.ViewHolder{
        private TextView indexTv;
        private TextView addressTv;
        public NewsViewHolder(View itemView) {
            super(itemView);
            indexTv = (TextView) itemView.findViewById(R.id.index);
            addressTv = (TextView) itemView.findViewById(R.id.address);
        }
    }
}
